



clear all 
use the_dataset.dta

keep if  standard == 1

keep culture1 culture2 culture_d  unemp culture1 case_1 case_2 CCAA1 ///
educ_basic1-educ_sup1 age051-age661 income1 income2 income_d NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 ANOENC1 yeardummy1-yeardummy9
global covariates1 culture1 income1 NMIEMB1 educ_basic1-educ_sup1 age051-age661 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9 size_dummy1-size_dummy5  number_spanish1

preserve

drop if case_1 != 1

* use seed 1, 2, or 3 for different iterations
set seed 1
* gen placebo treatments
forvalues i=1(1)2001{

gen ind_culture`i' = _n 
gen aux`i' = rnormal(0,1) 
sort aux`i'
gen placebo`i' = 1 in 1/2810
replace placebo`i' = 0 if placebo`i'!=1 
sort ind_culture`i'
drop ind_culture`i' aux`i'
}
*

gen est1 = 0 
gen se1 = 0
* estimate and save it
forvalues i=1(1)1119{

absdid culture_d, tvar(placebo`i') xvar($covariates1) sle 
matrix maest_`i' = e(b)
scalar scest_`i' = maest_`i'[1,1]

matrix mase_`i' = e(V)
scalar scse_`i' = sqrt(mase_`i'[1,1])

replace est1 = scest_`i' in `i'
replace se1  = scse_`i' in `i'
drop placebo`i' 
save placebo_did_1_1.dta, replace
}
*
forvalues i=1121(1)2001{

absdid culture_d, tvar(placebo`i') xvar($covariates1) sle 
matrix maest_`i' = e(b)
scalar scest_`i' = maest_`i'[1,1]

matrix mase_`i' = e(V)
scalar scse_`i' = sqrt(mase_`i'[1,1])

replace est1 = scest_`i' in `i'
replace se1  = scse_`i' in `i'
drop placebo`i' 
save placebo_did_1_1.dta, replace
}
scalar drop _all

gen t_estat_1 = est1/se1 

gen false_pos_10_1 = 1 if t_estat_1<= -1.64 | t_estat_1>=1.64
replace false_pos_10_1 = 0 if t_estat_1> -1.64 & t_estat_1<1.64

gen false_pos_5_1 = 1 if t_estat_1<= -1.96 | t_estat_1>=1.96
replace false_pos_5_1 = 0 if t_estat_1> -1.96 & t_estat_1<1.96

gen cont = _n
sum false_pos_5_1 false_pos_10_1 if cont<2001

save placebo_did_1_1.dta, replace
restore
